{% extends 'base.html' %}

{% block title %}Spellen{% endblock title %}

{% block user_menu %}

	{% if is_leraar %}
		<li><a href="{{ BASE_PATH }}game/new">Nieuw Spel</a></li>
		<li><a href="{{ BASE_PATH }}user/home">Groepen Overzicht</a></li>
	{% endif %}
	{% if is_beheerder %}
		<li><a href="{{ BASE_PATH }}user/newUser">Nieuwe Leraar</a></li>
	{% endif %}
	{% if is_groep %}
		<li><a href="#">Groep</a></li>
	{% endif %}

<li><a href="{{ BASE_PATH }}logout">Uitloggen?</a></li>
{% endblock user_menu %}

{% block body %}
		
	{% if not games %}
	<div class="post">
		<div class="post-bgtop">
			<div class="post-bgbtm">
				<h1 class="title"> Geen Spel </h1>
				<div class="entry">
					Er zijn nog geen spellen aanwezig in de database. Klik in de menubalk op 'Nieuw Spel' om er een te maken.
				</div>
			</div>
		</div>
	</div>		
	{% endif %}
	{% for game, users, mills in games %}
	<div class="post">
		<div class="post-bgtop">
			<div class="post-bgbtm">
				<h1 class="title"> Spel: {{ game.name|default:"missing" }} </h1>
				<div class="entry">
					<table>
						<tr>
							<td>Name: </td>
							<td>{{ game.name|default:"missing" }}</td>
							<td></td>
						</tr>
						<tr>
							<td>Round: </td>
							<td>{{ game.turn }}</td>
							<td></td>
						</tr>
						<tr>
							<td>Storm deze ronde: </td>
							<td>{{ game.storm }}</td>
							<td></td>
						</tr>
						{% if not mills %}
						<tr>
							<td>Mill:</td>
							<td>None</td>
							<td></td>
						</tr>
						{% endif %}
						{% for m in mills %}
						<tr>
							<td>Mill:</td>
							<td>{{ m.name|default:"missing"}}</td>
							<td>
								<table>
									<tr>
										<td>Diameter:</td>
										<td>{{ m.diameter|default:"0" }}</td>
										<td>Meter</td>
									</tr>
									<tr>
										<td>Capacity:</td>
										<td>{{ m.capacity|default:"0" }}</td>
										<td>MW</td>
									</tr>
									<tr>
										<td>Cost:</td>
										<td>{{ m.cost|default:"0" }}</td>
										<td>EUR</td>
									</tr>
								</table>
							</td>
						</tr>
						{% endfor %}
						{% if not users %}
						<tr>
							<td>Player:</td>
							<td>None</td>
							<td></td>
						</tr>
						{% endif %}
						{% for u in users %}
						<tr>
							<td>Player: </td>
							<td>{{ u.first_name|default:"missing" }}</td>
							<td></td>
						</tr>
						{% endfor %}
						<tr>
							<td><a href="{{ BASE_PATH }}game/editGame/{{ game.id }}">Edit</a></td>
							<td><a href="{{ BASE_PATH }}round/endRound/{{ game.id }}">Einde ronde</a></td>
							<td></td>
						</tr>
					</table>
				</div>
			</div>
		</div>
	</div>			
	{% endfor %}

{% endblock body %}